<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta content="width=device-width, initial-scale=1.0, user-scalable=no" name="viewport">
    <title>修改密码</title>
    <meta content="" name="keywords">
    <meta content="" name="description">
    <script src="js/rem.js"></script>
    <script src="js/jquery.min.js" type="text/javascript"></script>
    <link href="css/base.css" rel="stylesheet" type="text/css"/>
    <link href="css/page.css" rel="stylesheet" type="text/css"/>
    <link href="css/all.css" rel="stylesheet" type="text/css"/>
    <link href="css/mui.min.css" rel="stylesheet" type="text/css"/>
    <link href="css/loaders.min.css" rel="stylesheet" type="text/css"/>
    <link href="css/loading.css" rel="stylesheet" type="text/css"/>
    <link href="slick/slick.css" rel="stylesheet" type="text/css"/>
    <link href="css/mui.picker.min.css" rel="stylesheet" type="text/css"/>
    <link href="css/mui.picker.css" rel="stylesheet"/>
    <script type="text/javascript">
        $(window).load(function () {
            let loading = $(".loading")
            loading.addClass("loader-chanage");
            loading.fadeOut(300)
        });

        function isEmpty(val) {
            if (val === null || val === undefined || val === '') {
                return true;
            }
        }

        function updatePassword() {
            let oldPassword = $('#oldPassword').val();
            let newPassword = $('#newPassword').val();
            if (isEmpty(oldPassword) || isEmpty(newPassword)) {
                alert('密码不能为空');
                return;
            }
            $.ajax({
                url: 'api/user/updatePassword',
                type: 'POST',
                data: {
                    oldPassword: oldPassword,
                    newPassword: newPassword
                },
                headers: {
                    'AccessToken': window.localStorage.getItem('AccessToken')
                },
                success: function (result) {
                    if (result.code === 1) {
                        alert('密码修改成功');
                        location.replace('javascript:history.go(-1)');
                    } else {
                        alert(result.msg);
                    }
                }
            })
        }
    </script>
</head>
<!--loading页开始-->
<div class="loading">
    <div class="loader">
        <div class="loader-inner pacman">
            <div></div>
            <div></div>
            <div></div>
            <div></div>
            <div></div>
        </div>
    </div>
</div>
<!--loading页结束-->
<body>
<!--header star-->
<header class="mui-bar mui-bar1 mui-bar-nav mui-bar-nav1" id="header">
    <a class="btn" href="javascript:history.go(-1)">
        <i class="iconfont icon-fanhui"></i>
    </a>
    <div class="top-sch-box top-sch-boxtwo top-sch-boxthree flex-col">
        返回
    </div>
</header>
<!--header end-->

<div class="warp warpthree clearfloat">
    <div class="h-top h-toptwo clearfloat box-s">
        <p class="tu"><img src="img/touxiang.png"/></p>
        <p class="nr"></p>
    </div>
    <div class="apply recharge clearfloat">
        <div class="appxiugai clearfloat">
            <ul>
                <li class="ra3 fl">
                    <i class="iconfont icon-mima fl"></i>
                    <input id="oldPassword" placeholder="请输入原始密码" type="password"/>
                </li>
                <li class="ra3 fl">
                    <i class="iconfont icon-mima fl"></i>
                    <input id="newPassword" placeholder="请输入新密码" type="password"/>
                </li>
            </ul>
        </div>
        <div class="xia clearfloat">
            <a class="db fl btn ra3" onclick="updatePassword()">确定</a>
            <a class="db fr btn ra3" href="javascript:history.go(-1)">取消</a>
        </div>
    </div>
</div>

<!--footer star-->
<footer class="page-footer fixed-footer" id="footer">
    <ul>
        <li>
            <a href="index.html">
                <i class="iconfont icon-shouye"></i>
                <p>商城</p>
            </a>
        </li>
        <li>
            <a href="#">
                <i class="iconfont icon-erweima1"></i>
                <p>二维码</p>
            </a>
        </li>
        <li>
            <a href="#">
                <i class="iconfont icon-kefu1"></i>
                <p>客服</p>
            </a>
        </li>
        <li class="active">
            <a href="center.html">
                <i class="iconfont icon-yonghuming"></i>
                <p>我的</p>
            </a>
        </li>
    </ul>
</footer>
<!--footer end-->
</body>
<script src="js/jquery-1.8.3.min.js" type="text/javascript"></script>
<script src="js/mui.min.js"></script>
<script src="js/mui.picker.min.js"></script>
<script src="js/others.js"></script>
<script src="js/hmt.js" type="text/javascript"></script>
<script src="slick/slick.js" type="text/javascript"></script>
<!--插件-->
<link href="css/swiper.min.css" rel="stylesheet">
<script src="js/swiper.jquery.min.js"></script>
</html>
